package com.chance.cc.crawler.prod.command.trigger.domain.news.zhihu;

import com.chance.cc.crawler.core.CrawlerJob;
import com.chance.cc.crawler.meta.core.bean.CrawlerMetaConstant;
import com.chance.cc.crawler.prod.command.job.domain.news.zhihu.ZHSearchRealtimeCrawlerScheduleJob;
import com.chance.cc.crawler.prod.command.job.domain.news.zhihu.ZHSearchSimpleCrawlerSchedulerJob;
import com.chance.cc.crawler.prod.command.job.domain.news.zhihu.ZHSearchTraceAHourCrawlerScheduleJob;
import com.chance.cc.crawler.prod.command.job.domain.news.zhihu.ZHSearchTraceAWeekCrawlerScheduleJob;
import com.chance.cc.crawler.prod.command.trigger.CommonCrawlerSchedulerTrigger;

public class ZHSearchCrawlerSchedulerTrigger extends CommonCrawlerSchedulerTrigger {

    public static void main(String[] args) {
//        publishScheduleTriggerInfo();
//        publishAHourScheduleTriggerInfo();
    //    publishAWeekScheduleTriggerInfo();
//        publicSimpleScheduleTriggerInfo(ZHSearchTraceAWeekCrawlerScheduleJob.crawlerJob());

        publicSimpleScheduleTriggerInfo();
    }
    public static void publishScheduleTriggerInfo(){
        CrawlerJob crawlerJob = ZHSearchRealtimeCrawlerScheduleJob.crawlerJob();
        metaServiceCommand_17.addOrUpdateScheduleCrawlerTrigger(
                crawlerJob.generateCrawlerKey(),
                crawlerJob.generateCrawlerTriggerKey(),
                ZHSearchRealtimeCrawlerScheduleJob.domain,
                CrawlerMetaConstant.ScheduleJobTrigger_Cron,
                "0 0/20 * * * ?",
                "知乎实时采集任务，每二十分钟执行一次");
    }
    public static void publishAHourScheduleTriggerInfo(){
        CrawlerJob crawlerJob = ZHSearchTraceAHourCrawlerScheduleJob.crawlerJob();
        metaServiceCommand_17.addOrUpdateScheduleCrawlerTrigger(
                crawlerJob.generateCrawlerKey(),
                crawlerJob.generateCrawlerTriggerKey(),
                ZHSearchRealtimeCrawlerScheduleJob.domain,
                CrawlerMetaConstant.ScheduleJobTrigger_Cron,
                "0 0 0/1 * * ? *",
                "知乎一小时追溯采集任务，每一小时执行一次");
    }

    public static void publishAWeekScheduleTriggerInfo(){
        CrawlerJob crawlerJob = ZHSearchTraceAWeekCrawlerScheduleJob.crawlerJob();
        metaServiceCommand_17.addOrUpdateScheduleCrawlerTrigger(
                crawlerJob.generateCrawlerKey(),
                crawlerJob.generateCrawlerTriggerKey(),
                ZHSearchRealtimeCrawlerScheduleJob.domain,
//                CrawlerMetaConstant.ScheduleJobTrigger_Simple,
                CrawlerMetaConstant.ScheduleJobTrigger_Cron,
                "0 30 0 * * ?",
//                "",
                "知乎七天内追溯采集任务，每天0：10执行一次");
    }

    public static void publicSimpleScheduleTriggerInfo(){
        CrawlerJob crawlerJob = ZHSearchSimpleCrawlerSchedulerJob.crawlerJob();
        metaServiceCommand_17.addOrUpdateScheduleCrawlerTrigger(
                crawlerJob.generateCrawlerKey(),
                crawlerJob.generateCrawlerTriggerKey(),
                ZHSearchSimpleCrawlerSchedulerJob.domain,
                CrawlerMetaConstant.ScheduleJobTrigger_Simple,
                "",
                "知乎临时采集任务");
    }


    public static void publicSimpleScheduleTriggerInfo(CrawlerJob crawlerJob){
//        CrawlerJob crawlerJob = ZHSearchSimpleCrawlerSchedulerJob.crawlerJob();
        metaServiceCommand_17.addOrUpdateScheduleCrawlerTrigger(
                crawlerJob.generateCrawlerKey(),
                crawlerJob.generateCrawlerTriggerKey(),
                ZHSearchSimpleCrawlerSchedulerJob.domain,
                CrawlerMetaConstant.ScheduleJobTrigger_Simple,
                "",
                "知乎临时采集任务");
    }
}
